<template>
	<!-- 智能客服 -->
	<view>
		<!-- <button open-type="contact" style="border-radius: 0;display: flex;flex-direction: column;align-items: center;justify-content: center;">
			<image mode="widthFix" style="height:46rpx;width: 42rpx ;margin-bottom:10rpx;"></image>
			<text>客服</text>
		</button> -->
		<view>
			<view class="cha">
				<input class="uni-input" confirm-type="search" v-model="faqContent" placeholder="请输入您的问题" />
				<button size="mini" type="primary" @click="getAnswer" plain>查询</button>
			</view>
			<view v-if="answerList === null">
				抱歉没有找到您想要得答案！！！
			</view>
			<view v-if="answerList != null">
				为您找到如下答案：
				<view v-for="(item,index) in answerList" :key="index">
					答案 : {{item}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data() {
			return{
				faqContent:'',
				answerList:[],
			}
		},
		mounted() {
			
		},
		methods:{
			getAnswer(){
				uni.request({
				    url: `http://localhost:7000/customer/customer/questionAnswer/`, //接口地址。
				    data: {
						userId:2,
						userName:'自行测',
				        faqContent: this.faqContent
				    },
					method:'POST',
				    success: (res) => {
				        console.log(res)
						
						if( res.statusCode === 200 ){
							this.answerList = res.data
						}else{
							this.answerList = ""
						}
						
						
				    }
				});
			}
		}
	}
</script>

<style lang="scss">
	.cha{
		display: flex;
		.uni-input{
			width: 600rpx;
		}
	}
</style>
